package controllers;

import beans.LocalizedBean;
import connectivity.Dbmanager;
import connectivity.QueryManager;
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import javax.servlet.*;
import javax.servlet.http.*;

public class ViewQuestionController extends HttpServlet {

    /*
     * HTTP GET Request
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Dbmanager dbManager = new Dbmanager();
        dbManager.openConnection();
        QueryManager queryManager = new QueryManager(dbManager);
        ArrayList questions = new ArrayList();
        ArrayList questionsAnswered = new ArrayList();
        questions = queryManager.getQuestions(1);
        questionsAnswered = queryManager.getQuestionsAnswered(1);
        request.setAttribute("vragenUitSessie", questions);
        request.setAttribute("vragenBeantwoord", questionsAnswered);
        HttpSession sessie = request.getSession();
        sessie.setAttribute("vragenBeantwoord",questionsAnswered);
        sessie.setAttribute("vragenNietBeantwoord",questions);
        dbManager.closeConnection();
        String address = "/viewQuestion.jsp";
        RequestDispatcher dispatcher = request.getRequestDispatcher(address);
        dispatcher.forward(request, response);
    }
}